package main

import (
	"fmt"
	"log"
	"net/http"

	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.Default()
	r.MaxMultipartMemory = 8 << 20
	r.POST("/upload", func(c *gin.Context) {
		form, _ := c.MultipartForm()
		files := form.File["files[]"]
		for _, file := range files {
			log.Println(file.Filename)
			//指定上传路径，绝对路径，并且携带上文件名
			c.SaveUploadedFile(file, "D:\\uploadfiles\\"+file.Filename)
		}
		c.String(http.StatusOK, fmt.Sprintf("%d files upload!", len(files)))
	})
	r.Run(":8081")
	//curl -X POST "http://localhost:8081/upload" -F "files[]=@girl1.jpg" -F "files[]=@rain.jpg"  -H "Content-Type: multipart/form-data"
}
